# !/usr/bin/python3
# -*- coding:utf-8 -*-
# Author:WeiFeng Liu
# @Time: 2021/12/9 上午8:19
import cv2
import glob
import os

def video_to_frame(save_path,video_path):
    video = cv2.VideoCapture(video_path)
    index = 0
    count = 0
    if video.isOpened():
        rval,frame = video.read()
    else:
        rval = False
    while rval:
        # print(index)
        rval,frame = video.read()
        if(index % 10 == 0 ):
            cv2.imwrite(save_path + '/' + str(count)+'.jpg',frame)
            count+=1
        index += 1

if __name__ == "__main__":
    video_to_frame(video_path="datasets/lane.mp4",
                    save_path="datasets/Image/",
                    )
    print("succeed")
